package demo06234;
public class WechatPayment implements Payment {
    private double balance;
    private String account;

    public WechatPayment(double balance, String account) {
        this.balance = balance;
        this.account = account;
    }

    @Override
    public boolean pay(double amount) {
        if (balance >= amount) {
            balance -= amount;
            System.out.printf("微信(%s)支付成功: %.2f元\n", account, amount);
            return true;
        } else {
            System.out.println("微信余额不足，支付失败");
            return false;
        }
    }

    @Override
    public double getBalance() {
        return balance;
    }

    @Override
    public String getPaymentName() {
        return "微信支付";
    }
}